package com.briup.product_source.controller;

import com.briup.product_source.pojo.QuarantineRegistration;
import com.briup.product_source.result.Result;
import com.briup.product_source.service.QuarantineRegistrationService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = "检疫登记模块")
@RestController
@RequestMapping("/quarantineRegistration")
public class QuarantineController {
    @Autowired
    private QuarantineRegistrationService qrService;
    //分页+条件查询检疫记录
    @GetMapping
    @Operation(summary = "分页+条件查询检疫记录")
    @Parameters({
            @Parameter(name = "pageNum",description = "当前页码",in = ParameterIn.QUERY),
            @Parameter(name = "pageSize",description = "每页大小",in = ParameterIn.QUERY),
            @Parameter(name = "mechanism",description = "检疫机构",in = ParameterIn.QUERY),
            @Parameter(name = "bQualified",description = "检疫结果",in = ParameterIn.QUERY),
    })
    public Result findByPage(Integer pageNum, Integer pageSize, @RequestParam(required = false) String mechanism,
                                          @RequestParam(required = false) String bQualified){
        return Result.success(qrService.findByPage(pageNum,pageSize,mechanism, bQualified));
    }
    @Operation(summary = "添加或修改检疫等级信息")
    @PostMapping("/saveOrUpdate")
    public Result reviseQuarantineRegistrationInfo(@RequestBody QuarantineRegistration recode)
    {
        qrService.saveOrUpdate(recode);
        return Result.success();
    }
}